package chapter2.No2_3_volatile关键字.e使用原子类进行i加加操作;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * !
 *
 * @author liujian
 * @version 2016/11/16 0016
 */
public class ServiceClass {

    AtomicInteger count = new AtomicInteger(0);
//    int count;

    public void addCount() {
        for (int i = 0; i < 100; i++) {
            // 线程安全
            count.incrementAndGet();
            // 非线程安全
//            count++;
        }
        System.out.println(count);
    }
}
